package friot.service.cloud.service;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import friot.model.iot.entity.IotModel;
import friot.service.cloud.mapper.IotModelMapper;
import friot.utils.constants.AppHttpCodeEnum;
import friot.utils.exception.ServiceException;
import org.springframework.stereotype.Service;

/**
 * (IotModel)表服务实现类
 *
 * @author makejava
 * @since 2024-02-20 15:22:38
 */
@Service("iotModelService")
public class IotModelServiceImpl extends ServiceImpl<IotModelMapper, IotModel> implements IotModelService {

    /**
     * 保存数据
     *
     * @param iotModel 数据模型
     */
    @Override
    public void saveModel(IotModel iotModel) {
        // 参数校验
        if (StringUtils.isBlank(iotModel.getModelName())) {
            throw new ServiceException(AppHttpCodeEnum.PARAM_REQUIRE);
        }
        if (StringUtils.isBlank(iotModel.getIdentified())) {
            throw new ServiceException(AppHttpCodeEnum.PARAM_REQUIRE);
        }
        if (StringUtils.isBlank(iotModel.getUnit())) {
            throw new ServiceException(AppHttpCodeEnum.PARAM_REQUIRE);
        }

        // 保存数据
        this.save(iotModel);
    }
}

